package com.blog;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;

import java.net.InetAddress;
import java.net.UnknownHostException;


/**
 *
 * 启动类
 * @author cgx
 */
@SpringBootApplication
@MapperScan("com.blog.mapper")
public class BlogApplication {

    public static void main(String[] args) throws UnknownHostException {
        ConfigurableApplicationContext application = SpringApplication.run(BlogApplication.class, args);
        Environment env = application.getEnvironment();
        String ip = InetAddress.getLocalHost().getHostAddress();
        String port = env.getProperty("server.port");
        String path = env.getProperty("server.servlet.context-path")==null?"":env.getProperty("server.servlet.context-path");
        System.err.println(
                "\n----------------------------------------------------------\n\t"
                        +"Blog 启动成功 ! Access URLs:\n\t"
                        + "Local: \t\thttp://localhost:" + port + path+ "\n\t"
                        + "External: \thttp://" + ip + ":"+ port +path +"\n"
                        + "----------------------------------------------------------");
    }


}
